package cn.mldn.lzs.dbc;

/**
 * Created by Administrator on 2017/4/2.
 */
import java.sql.Connection;
import java.sql.DriverManager;



public class DatabaseConnection {
    private static final String DBDRIVER = "com.mysql.jdbc.Driver";
    private static final String DBURL = "jdbc:mysql://localhost:3306/mldn?characterEncoding=utf8&useSSL=true";
    private static final String DBUSER = "root";
    private static final String DBPASS = "root";
    private Connection conn = null;

    public DatabaseConnection() throws Exception{
        try {
            Class.forName(DBDRIVER);
            this.conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS);
        }catch (Exception e){
            throw e;
        }
    }
    public Connection getConnection(){
        return this.conn;
    }
    public void close() throws Exception{
        if (this.conn != null){
            try {
                this.conn.close();
            }catch (Exception e){
                throw e;
            }

        }
    }
}
